<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>实现数学对象函数的封装</title>
		<script>
			function arrMax(arr){
				var max = arr[0];
				for(var i=0; i<arr.length; i++){
					if(arr[i] > max){
						max = arr[i]
					}
				}
				return max;
			}
			var arr = [100,87,45,12,5,54,23];
			var m = arrMax(arr);
			console.log(m);
			
			function arrMin(arr){
				var min = arr[0];
				for(var i=0; i<arr.length; i++){
					if(arr[i] < min){
						min = arr[i]
					}
				}
				return min;
			}
			var m = arrMin(arr);
			console.log(m);
			
			function arrSum(arr){
				var sum = 0;
				for(var i=0; i<arr.length; i++){
					sum+=arr[i];
				}
				return sum;
			}
			var m = arrSum(arr);
			console.log(m);
			
			function arrAvg(arr){
				var sum = arrSum(arr);
				return sum/arr.length;
			}
			
			var m = arrAvg(arr);
			console.log(m);
			
		
			
		</script>
	</head>
	<body>
	</body>
</html>